using System;
using System.Collections.Generic;
using System.Text;
using Blazing.BusinessObjects.Cms;

using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute;
using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute;


namespace BusinessObjectTests
{
    [TestClass]
    public class MenuItemTests : NHibernateInMemoryTestFixtureBase
    {
        private void CheckValues(MenuItem obj, MenuItem newObj)
        {
            Assert.AreEqual(obj.ID, newObj.ID);
            Assert.AreEqual(obj.Label, newObj.Label);
            Assert.AreEqual(obj.Menu.ID, newObj.Menu.ID);
            Assert.AreEqual(obj.Parent.ID, newObj.Parent.ID);
            Assert.AreEqual(obj.SortOrder, newObj.SortOrder);
            Assert.AreEqual(obj.Title, newObj.Title);
            Assert.AreEqual(obj.RowStamp, newObj.RowStamp);
        }

        [TestMethod]
        public void CreateMenuItem()
        {
            MenuItem obj = BusinessObjectFactory.CreateAndFillMenuItem();
            MenuItem parent = BusinessObjectFactory.CreateAndFillMenuItem();
            Menu menu = BusinessObjectFactory.CreateAndFillMenu();
            MenuType type = BusinessObjectFactory.CreateAndFillMenuType();
            Site site = BusinessObjectFactory.CreateAndFillSite();

            site.Save();
            type.Save();
            menu.Site = site;
            menu.MenuType = type;
            menu.Save();

            parent.Menu = menu;
            parent.Save();

            obj.Parent = parent;
            obj.Menu = menu;
            obj.Save();

            MenuItem obj2 = MenuItem.Load(obj.ID);

            CheckValues(obj, obj2);

            obj.Delete();
            obj.Save();

            parent.Delete();
            parent.Save();
            menu.Delete();
            menu.Save();
            type.Delete();
            type.Save();
        }
    }
}
